<?php
/**
 * Created by PhpStorm.
 * User: alice
 * Date: 2016/1/14
 * Time: 11:06
 */

class Involved_LevelModel extends BaseModel{

    protected $table = 'level';


    /********************************   APP接口   *****************************/

    /**
     * 获取规格等级
     * @param $cate_id
     * @return array
     */
    public function GetLevelList($cate_id)
    {
        return DB::table($this->table)
                ->selectRaw('level_id as id,level_name as name')
                ->where('quality',$cate_id)
                ->get();
    }


    /********************************   PC   *****************************/

    /**
     * 获取等级列表
     * @return mixed
     * @author alice
     * @date 2016-1-25
     */
    public function ShowLevelList()
    {
        return DB::table($this->table)->paginate(10);
    }

    /**
     * 等级详情
     * @param $id
     * @return mixed
     * @author alice
     * @date 2016-1-25
     */
    public function GetLevelInfo($id)
    {
        return DB::table($this->table)
                ->where('level_id',$id)
                ->first();
    }

    /**
     * 获取等级名称
     * @param $level_id
     * @return mixed
     */
    public function GetLevelNameById($level_id)
    {
        $level =  $this->GetLevelInfo($level_id);
        return ($level && property_exists($level,'level_name')) ? $level->level_name : "未知";
    }

    /**
     * 获取规格列表
     * @author fyl
     * @date 2016-4-05
     */
    public function AdminProductLevelList()
    {
        return DB::table($this->table)->get();
    }


}